// 表单验证
import VeeValidate from 'vee-validate'

// 引入表单验证中文包
import zh_CN from 'vee-validate/dist/locale/zh_CN'

export default function (Vue) {
    Vue.use(VeeValidate)

    VeeValidate.Validator.localize('zh_CN', {
        messages: {
            // 展开中文包
            ...zh_CN.messages,
            regex: (m) => `${m}不符合规则`,
            is: (m) => `${m}与密码值不一致`
        },
        // 对字段进行中文匹配
        attributes: {
            phone: '手机号',
            verifyCode: '验证码',
            password: '密码',
            passAgain: '确认密码',
            agree: '用户协议'

        }
    })

    VeeValidate.Validator.extend('agree', {
        validate: value => value,

        getMessage: m => m + '必须同意'
    },
    )
}
